'''
1、登录页面的表单获取
2、通过selenium登录
3、登录获取cookies值，用来访问各个页面获取表单
'''

from selenium import webdriver
from selenium.webdriver.support.ui import Select
from the_get_res import res1
import random
from selenium.webdriver.common.keys import Keys


class AutoInit(object):

    def __init__(self):
        # 设置初始条件
        self.url = r'http://localhost:8080/itm.supplier.client/login.jsp'
        browser = webdriver.Firefox(executable_path=r'D:\anaconda\Scripts\geckodriver.exe')
        self.browser = browser

    def login_set(self):
        # 登录
        try:
            self.browser.get(self.url)
            self.browser.implicitly_wait(10)
            # self.browser.find_element_by_id('username').send_keys('xfdj')
            self.browser.find_element_by_name('passWord').send_keys('123')
            self.browser.find_element_by_id('userLoginBtn').click()
            cookies = self.browser.get_cookies()
            get_cookies = {cookies[0]['name']:cookies[0]['value']}
        except:
            pass

    

t = AutoInit()
t.login_set()